package com.mercury.pattern._17_mediator;

import java.util.HashMap;
import java.util.Map;

public class ConcreateMediator implements Mediator {

    Map<Class,Person> persons;

    public ConcreateMediator() {
        persons = new HashMap<>();
    }

    @Override
    public void addPerson(Class clazz, Person person) {
        persons.put(clazz,person);
    }

    @Override
    public void talk(String msg,Person person) {
        //如果是房东通过中介者发的消息,那么就是租客获取消息
        if (person instanceof HouseOwner){
            persons.get(Renters.class).getMsg(msg);
        }else{
            persons.get(HouseOwner.class).getMsg(msg);
        }
    }
}
